#include "dsp.h"
#include <vector>
#include <cstdio>
#include <iostream>

int main()
{

    // determine a dsp
    std::vector<int> v1{0, 1, 2};
    std::vector<int> v2{0, 3, 6, 9, 12};
    bool isdsp = isDsp(v1, v2, 15, 1);
    printf("isdsp = %d\n", isdsp);

    // use the struct way
    Dsp dsp{15, 3, 5, 1, 1};
    dsp.k1Set = new unsigned char[dsp.k1];
    dsp.k2Set = new unsigned char[dsp.k2];
    dsp.diffTable = new unsigned char[dsp.k1 * dsp.k2];
    for (int i = 0; i < v1.size(); i++)
    {
        dsp.k1Set[i] = v1[i];
    }

    for (int j = 0; j < v2.size(); j++)
    {
        dsp.k2Set[j] = v2[j];
    }

    bool valid = initializeDsp(&dsp);
    printf(valid ? "valid\n" : "invalid\n");
    // release resource
    delete[] dsp.k1Set;
    delete[] dsp.k2Set;

    // test read in dsp
    std::vector<Dsp> dsps = readDsp("dsp-15-3-5-1-1.txt");
    for (Dsp dsp : dsps)
    {
        std::cout << dsp << std::endl;
    }
}